﻿using Abp.EntityFramework;
using Aceso.LOreal.Entities;
using Aceso.LOreal.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aceso.LOreal.EntityFramework.Repositories
{
    public class VendorRepository : LOrealRepositoryBase<Vendor, Guid>, IVendorRepository
    {
        public VendorRepository(IDbContextProvider<LOrealDbContext> dbContextProvider)
            : base(dbContextProvider)
        {

        }

        public List<Vendor> GetVendorsByName(string name)
        {
            var query = GetAll();//GetAll()返回一个IQueryable<T>，我们可以通过它来查询
            var query2 = Context.Vendors.AsQueryable();//也可以直接使用EF的DbContext对象
            if (!string.IsNullOrEmpty(name))
            {
                query = query.Where(c => c.Name.Contains(name));
            }
            return query.ToList();
        }
    }
}
